package com.example.fw;

import java.io.IOException;
import java.util.Properties;

public class AppManager {
	
	private ContactsHelper contactsHelper;
    private Process exec;
    private Properties props;
    private AutoItHelper autoItHelper;

    public AppManager(Properties properties) throws IOException {
        this.props = properties;
        startApp();
	}
	
	public void stopApp() {
        exec.destroy();
	}

    public void startApp() throws IOException {
        String command = props.getProperty("app.path");
        exec = Runtime.getRuntime().exec(command);
    }

	public ContactsHelper getContactsHelper() {
		if (contactsHelper == null) {
			contactsHelper = new ContactsHelper(this);
		}
		return contactsHelper;
	}

    public AutoItHelper getAutoItHelper() {
        if (autoItHelper == null) {
            autoItHelper = new AutoItHelper(this);
        }
        return autoItHelper;
    }

    public Properties getProps() {
        return props;
    }
}
